﻿using EasyNetQ;
using EasyNetQ.AutoSubscribe;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Mysoft.Common.Configuration;
using Mysoft.Tasks.Queue.RabbitMQ.Extensions;
using Mysoft.Tasks.Queue.RedisMQ.Extensions;
using System.Reflection;

namespace Mysoft.AppStartup.Application
{

    /// <summary>
    /// RabbitMQ队列订阅 
    /// </summary>
    public static class UseRabbitMQSubscribe
    {
        public static void UseSubscribe(this WebApplication appBuilder)
        {
            var services = appBuilder.Services;
            //是否启用RedisMQ
            if (AppSetting.UseRabbitMQ)
            {
                services.RabbitMQEventBusAutoSubscribe();
            }
            else {

                services.RedisMQEventBusAutoSubscribe();
            }
               
        }
    }
}
